<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Get or set flags on function or class</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="function.uopz-extend.html">« uopz_extend</a></li>
      <li style="float: right;"><a href="function.uopz-function.html">uopz_function »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="ref.uopz.html">Uopz 函数</a></li>
    <li>Get or set flags on function or class</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="function.uopz-flags" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">uopz_flags</h1>
  <p class="verinfo">(PECL uopz 2 &gt;= 2.0.2, PECL uopz 5, PECL uopz 6, PECL uopz 7)</p><p class="refpurpose"><span class="refname">uopz_flags</span> &mdash; <span class="dc-title">Get or set flags on function or class</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.uopz-flags-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>uopz_flags</strong></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$function</code></span>, <span class="methodparam"><span class="type">int</span> <code class="parameter">$flags</code><span class="initializer"> = PHP_INT_MAX</span></span>): <span class="type">int</span></div>

  <div class="methodsynopsis dc-description"><span class="methodname"><strong>uopz_flags</strong></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$class</code></span>, <span class="methodparam"><span class="type">string</span> <code class="parameter">$function</code></span>, <span class="methodparam"><span class="type">int</span> <code class="parameter">$flags</code><span class="initializer"> = PHP_INT_MAX</span></span>): <span class="type">int</span></div>

  <p class="para rdfs-comment">
 Get or set the flags on a class or function entry at runtime
  </p>

 </div>


 <div class="refsect1 parameters" id="refsect1-function.uopz-flags-parameters">
  <h3 class="title">参数</h3>
  <dl>
   
    <dt>
<code class="parameter">class</code></dt>

    <dd>

     <p class="para">
 The name of a class
     </p>
    </dd>

   
   
    <dt>
<code class="parameter">function</code></dt>

    <dd>

     <p class="para">
      The name of the function. If <code class="parameter">class</code> is given and an empty string
      is passed as <code class="parameter">function</code>, <span class="function"><strong>uopz_flags()</strong></span>
      gets or sets the flags of the class entry.
     </p>
    </dd>

   
    
    <dt>
<code class="parameter">flags</code></dt>

    <dd>

     <p class="para">
 A valid set of ZEND_ACC_ flags.
      If omitted, <span class="function"><strong>uopz_flags()</strong></span> acts as getter.
     </p>
    </dd>

   
  </dl>

 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.uopz-flags-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
 If setting, returns old flags, else returns flags
  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-function.uopz-flags-errors">
  <h3 class="title">错误／异常</h3>
  <p class="simpara">
   As of PHP 7.4.0, if the parameter <code class="parameter">flags</code> is passed,
   <span class="function"><strong>uopz_flags()</strong></span> throws a <span class="classname"><a href="class.runtimeexception.html" class="classname">RuntimeException</a></span>,
   if <a href="book.opcache.html" class="link">OPcache</a> is enabled,
   and the class entry of <code class="parameter">class</code>
   or the function entry of <code class="parameter">function</code> is immutable.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.uopz-flags-changelog">
  <h3 class="title">更新日志</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>版本</th>
      <th>说明</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>PECL uopz 5.0.0</td>
      <td>
       The <code class="parameter">flags</code> parameter is now optional. Formerly,
       <strong><code>ZEND_ACC_FETCH</code></strong> had to be passed to use <span class="function"><strong>uopz_flags()</strong></span>
       as getter.
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 examples" id="refsect1-function.uopz-flags-examples">
  <h3 class="title">范例</h3>
  <div class="example" id="example-619">
   <p><strong>示例 #1 <span class="function"><strong>uopz_flags()</strong></span> example</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">class&nbsp;</span><span style="color: #0000BB">Test&nbsp;</span><span style="color: #007700">{<br />&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;function&nbsp;</span><span style="color: #0000BB">method</span><span style="color: #007700">()&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;</span><span style="color: #0000BB">__CLASS__</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />}<br /><br /></span><span style="color: #0000BB">$flags&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">uopz_flags</span><span style="color: #007700">(</span><span style="color: #DD0000">"Test"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"method"</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">((bool)&nbsp;(</span><span style="color: #0000BB">uopz_flags</span><span style="color: #007700">(</span><span style="color: #DD0000">"Test"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"method"</span><span style="color: #007700">)&nbsp;&amp;&nbsp;</span><span style="color: #0000BB">ZEND_ACC_PRIVATE</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">((bool)&nbsp;(</span><span style="color: #0000BB">uopz_flags</span><span style="color: #007700">(</span><span style="color: #DD0000">"Test"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"method"</span><span style="color: #007700">)&nbsp;&amp;&nbsp;</span><span style="color: #0000BB">ZEND_ACC_STATIC</span><span style="color: #007700">));<br /><br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">uopz_flags</span><span style="color: #007700">(</span><span style="color: #DD0000">"Test"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"method"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$flags</span><span style="color: #007700">|</span><span style="color: #0000BB">ZEND_ACC_STATIC</span><span style="color: #007700">|</span><span style="color: #0000BB">ZEND_ACC_PRIVATE</span><span style="color: #007700">));<br /><br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">((bool)&nbsp;(</span><span style="color: #0000BB">uopz_flags</span><span style="color: #007700">(</span><span style="color: #DD0000">"Test"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"method"</span><span style="color: #007700">)&nbsp;&amp;&nbsp;</span><span style="color: #0000BB">ZEND_ACC_PRIVATE</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">((bool)&nbsp;(</span><span style="color: #0000BB">uopz_flags</span><span style="color: #007700">(</span><span style="color: #DD0000">"Test"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"method"</span><span style="color: #007700">)&nbsp;&amp;&nbsp;</span><span style="color: #0000BB">ZEND_ACC_STATIC</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

   <div class="example-contents"><p>以上例程会输出：</p></div>
   <div class="example-contents screen">
<div class="cdata"><pre>
bool(false)
bool(false)
int(1234567890)
bool(true)
bool(true)
</pre></div>
   </div>
  </div>
  <div class="example" id="example-620">
   <p><strong>示例 #2 &quot;Unfinalize&quot; a Class</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">final&nbsp;class&nbsp;</span><span style="color: #0000BB">MyClass<br /></span><span style="color: #007700">{<br />}<br /><br /></span><span style="color: #0000BB">$flags&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">uopz_flags</span><span style="color: #007700">(</span><span style="color: #0000BB">MyClass</span><span style="color: #007700">::class,&nbsp;</span><span style="color: #DD0000">''</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">uopz_flags</span><span style="color: #007700">(</span><span style="color: #0000BB">MyClass</span><span style="color: #007700">::class,&nbsp;</span><span style="color: #DD0000">''</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$flags&nbsp;</span><span style="color: #007700">&amp;&nbsp;~</span><span style="color: #0000BB">ZEND_ACC_FINAL</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">((new&nbsp;</span><span style="color: #0000BB">ReflectionClass</span><span style="color: #007700">(</span><span style="color: #0000BB">MyClass</span><span style="color: #007700">::class))-&gt;</span><span style="color: #0000BB">isFinal</span><span style="color: #007700">());<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

   <div class="example-contents"><p>以上例程会输出：</p></div>
   <div class="example-contents screen">
<div class="cdata"><pre>
bool(false)
</pre></div>
   </div>
  </div>
 </div>


</div></div></div></body></html>